/**
 * Copyright 2016-2018 mobaas.com
 */
package com.mobaas.devops;

/**
 * HTTP方式health结果
 * @author billy zhang
 *
 */
public class HttpHealthResult implements HealthResult {

	private int reqStatus;
	private String reqError;
	
	private int httpStatus;
	private String content;

	@Override
	public boolean isOk() {
		return 200 == httpStatus;
	}
	
	public int getReqStatus() {
		return reqStatus;
	}
	public void setReqStatus(int reqStatus) {
		this.reqStatus = reqStatus;
	}
	
	public String getReqError() {
		return reqError;
	}
	public void setReqError(String reqError) {
		this.reqError = reqError;
	}
	public int getHttpStatus() {
		return httpStatus;
	}
	public void setHttpStatus(int httpStatus) {
		this.httpStatus = httpStatus;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	
	public boolean isSuccess() {
		return reqStatus == 0 && httpStatus < 300;
	}
	
	public String getInfo() {
		return String.format("httpStatus: %d, Content: %s, reqStatus: %d, reqError: %s", 
				httpStatus, content, reqStatus, reqError);
	}
}
